/**
 * 移动端全局AJAX请求拦截器，请求成功完后会首先执行这段代码
 */
jQuery(function ($) {
    // 备份jquery的ajax方法
    var _ajax = $.ajax;
    // 重写ajax方法，先判断登录在执行success函数
    $.ajax = function (opt) {
        var _success = opt && opt.success || function (a, b) {};
        var _opt = $.extend(opt, {
            success: function (data, textStatus) {
                //用户登录失效
                if (data.status == -1) {
                    $(".web_toast").fadeOut();
                    sessionStorage.removeItem(SCS_USER_NAME);
                    popTipShow.confirm('登录确认','登录失效，请重新登录',['去登录','不去'],function(e){
                        if($(e.target).attr('class') != 'ok'){
                            this.hide();
                            return;
                        }
                        window.location.href = '/userPages/mobile/mUserLogin.html';
                    });
                    var a = document,c = $('.confirmMode'),b = a.documentElement,g = a.body,e, d, f;
                    a = g.scrollTop;
                    g = g.scrollLeft;
                    e = b.clientWidth;
                    b = b.clientHeight;
                    d = c.width();
                    f = c.height();
                    c.addClass('show').css('cssText','display:block !important;').css({top: a + (b - f) / 2,left: g + (e - d) / 2});
                    return;
                }
                _success(data, textStatus);
            }
        });
        //继续执行原AJAX请求
        _ajax(_opt);
    };
});